package realQuestion.aiShu;

import java.util.ArrayList;
import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String next = scanner.nextLine();
        String[] s = next.split(" ");
        int[] nums = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            nums[i]=Integer.valueOf(s[i]);
        }
        for (int a: nums) {
            System.out.println(a);
        }
        System.out.println(find(nums));

    }

    public   static  int find(int[] nums){
        if (nums.length==0){
            return  0;
        }
        int[] dp=new int[nums.length];
        dp[0]=nums[0];
        int max=Integer.MIN_VALUE;
        for (int i = 1; i < nums.length ; i++) {
            dp[i]=Math.max(dp[i-1]+ nums[i],nums[i]);
            max=Math.max(dp[i],max);
        }
        return  max>dp[0]?max:dp[0];
    }
}

//    select DISTINCT num AS consecutiveNums
//from(
//                select num,LAG(num) OVER (ORDER BY id) AS  prev_num,
//        LEAD(num)  OVER(ORDER BY id) AS  next_num
//        from  Logs
//        ) AS  t  where num=prev_num and num<> next_num  order by num;
